using KL.Standard.Model.Contant;

namespace KL.Standard.Model.Attribute;

/// <summary>
/// 用于redis缓存之用
/// </summary>
[AttributeUsage(AttributeTargets.Method, Inherited = true)]
public class CacheAttribute: System.Attribute
{
    /// <summary>
    /// 缓存转换的类型
    /// </summary>
    public Type entityType { get; set; }
    /// <summary>
    /// 缓存key
    /// </summary>
    public string cacheKey { get; set; }

    /// <summary>
    /// 缓存key的前缀
    /// </summary>
    public string keyPrefix { get; set; } = "";

    /// <summary>
    /// 是否要忽略方法名字
    /// </summary>
    public bool ignoreMethodName { get; set; } = true;
    /// <summary>
    /// 忽略参数
    /// </summary>
    public bool ignoreParam { set; get; } = true;

    /// <summary>
    /// 如果 ignoreParam= false 则参数类型是必须；
    /// </summary>
    public Type paramType { set; get; }
    /// <summary>
    /// 缓存操作类型
    /// </summary>
    public string opeType { set; get; } = CacheOpeTypeContant.GET_AND_SAVE;

    /// <summary>
    /// 缓存超时时间（秒）
    /// 如果设置0 表示不过期
    /// </summary>
    public double cacheExpireSecd { set; get; } = 60;

}